/*************************************************************************
	> File Name: P1031.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-23 14:30:07
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 100

int arr[MAX_N + 5];

int main() {
    int n, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    int ave = sum / n, cnt = 0;
    for (int i = 0; i < n; i++) {
        if (arr[i] == ave) continue;
        int temp = 0;
        if (arr[i] < ave) {
            temp = ave - arr[i];
            arr[i + 1] -= temp;
            arr[i] = ave;
            cnt += 1;
        } else {
            temp = arr[i] - ave;
            arr[i + 1] += temp;
            arr[i] = ave;
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}
